package org.gourpg.entity.menu;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.proxy.HibernateProxy;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.sql.Date;
import java.util.Objects;

@Entity
@Getter
@Setter
@ToString
@RequiredArgsConstructor
/**
 * 路由功能配置实体
 */
@Table(name = "route_detail")
public class RouteDetail {
    @Id
    private Long id;
    /**
     * 路由路径
     */
    private String routePath;

    /**
     * 路由HTTP方法
     */
    private String routeMethod;

    /**
     * 路由源码路径（能解析到就要，解析不到就算了）
     */
    private String routeClass;

    /**
     * 路由来源，通常为系统名称
     */
    private String routeSource;

    /**
     * 路由新增日期
     */
    private Date routeStartDate;

    /**
     * 路由消失日期
     */
    private Date routeEndDate;

    /**
     * 路由功能类型（管理、维护、查看）字典：POWER_TYPE
     */
    private String routeType;

    /**
     * 路由当前状态（正在使用、失效）字典：ROUTE_STATUS
     */
    private String routeStatus;

    /**
     * 功能名称
     */
    private String routeName;

    /**
     * 功能说明
     */
    private String routeRemark;

    @Override
    public final boolean equals(Object o) {
        if (this == o) return true;
        if (o == null) return false;
        Class<?> oEffectiveClass = o instanceof HibernateProxy ? ((HibernateProxy) o).getHibernateLazyInitializer().getPersistentClass() : o.getClass();
        Class<?> thisEffectiveClass = this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass() : this.getClass();
        if (thisEffectiveClass != oEffectiveClass) return false;
        RouteDetail that = (RouteDetail) o;
        return getId() != null && Objects.equals(getId(), that.getId());
    }

    @Override
    public final int hashCode() {
        return this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass().hashCode() : getClass().hashCode();
    }
}
